<?php
namespace ManiaLivePlugins\MLEPP\Votes\Gui\Controls;

use ManiaLib\Gui\Elements\BgsPlayerCard;
use ManiaLib\Gui\Elements\Bgs1InRace;
use ManiaLib\Gui\Elements\Icons64x64_1;
use ManiaLib\Gui\Elements\Icons128x128_1;
use ManiaLib\Gui\Elements\BgRaceScore2;
use ManiaLib\Gui\Elements\Quad;
use ManiaLib\Gui\Elements\Label;
use ManiaLivePlugins\MLEPP\Core\Core;
use ManiaLib\Gui\Elements\Format;

class Button extends \ManiaLive\Gui\Windowing\Control
{
	public $callBack;
	private $param;
	//private $btn;
	private $btn1;
	private $lbl;



	function initializeComponents()
	{
		$this->param = $this->getParam(1);
		$this->sizeX = 18;
		$this->sizeY = 5;

//		$this->btn = new Quad();
//		$this->btn->setStyle("Bgs1InRace");
//		$this->btn->setSubStyle("BgTitle3");
//		$this->btn->setPosX(($this->sizeX / 2));
//		$this->btn->setPosY(0);
//		
//		$this->btn->setHalign("center");
//
//	//	$this->btn->setPosition(($this->sizeX / 2) - 7, 4);
//		$this->addComponent($this->btn);
		
		$this->btn1 = new Quad();
		$this->btn1->setStyle("Bgs1");
		$this->btn1->setSubStyle("BgCard1");
		$this->btn1->setPosX(($this->sizeX / 2));
		$this->btn1->setPosY(0);
		
		$this->btn1->setHalign("center");

	//	$this->btn->setPosition(($this->sizeX / 2) - 7, 4);
		$this->addComponent($this->btn1);

		$this->lbl = new Label();
		$this->lbl->setTextSize(2);
		$this->lbl->setStyle(Format::TextButtonNav);
		
		$this->lbl->setPosX(($this->sizeX / 2));
		$this->lbl->setPosY(1.5);
		$this->lbl->setHalign("center");
		$this->lbl->setText('$222'.$this->getParam(0));
		$this->lbl->setScale(0.8);
		//$this->lbl->setPosition( ($this->sizeX / 2), 1.5);
		$this->addComponent($this->lbl);

	}

	function beforeDraw()
	{

		//$this->btn->setSize(20, 5);
		$this->lbl->setSize(20, 5);
		$this->btn1->setSize(20, 5);
		
		if ($this->param == "yes"){
		$this->btn1->setActionKey(1);
		$this->btn1->setAction($this->callback('onClicked'));
		}
		
		if ($this->param == "no"){
		$this->btn1->setActionKey(2);
		$this->btn1->setAction($this->callback('onClicked'));
		}
		
		if ($this->param == "pass"){
		$this->btn1->setAction($this->callback('onClicked'));
		}
		
		if ($this->param == "cancel"){
		$this->btn1->setAction($this->callback('onClicked'));
		}
		
		//$this->btn->setVisibility(true);
		$this->btn1->setVisibility(true);
		$this->lbl->setVisibility(true);

	}

	function onResize()
	{
	}

	function afterDraw() {}

	function onClicked($login)
	{
		call_user_func($this->callBack, $login, $this->param);
	}

	function destroy()
	{
		$this->callBack = null;
		parent::destroy();
	}
}
?>